package avicit.bdp.dcs.task.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.bdp.common.utils.database.ColumnInfo;
import avicit.bdp.dcs.semistructure.dto.HiveJsonDto;
import avicit.bdp.dcs.semistructure.dto.IotdbJsonDto;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2020-08-10 11:56
 * @类说明：任务实体类
 * @修改记录：
 */
@ApiModel(value = "TaskDTO", description = "bdp_dcs_task")
@Table(name = "bdp_dcs_task")
public class TaskDTO extends BaseDTO {

    private static final long serialVersionUID = 1L;

     /** 主键 */
    @Id
    @LogField
    @ApiModelProperty(value = "主键")
    @FieldRemark(column = "id", field = "id", name = "id")
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

     /** 迁移id，同步id */
    @LogField
    @ApiModelProperty(value = "迁移id，同步id")
    @FieldRemark(column = "job_id", field = "jobId", name = "迁移或同步ID")
    @Column(name = "job_id")
    private String jobId;

     /** 类型:
      * 数据迁移：1
      * 数据同步：2
      * 半结构化采集：3
      */
    @LogField
    @ApiModelProperty(value = "类型，数据迁移：1，数据同步：2，半结构化采集：3")
    @FieldRemark(column = "job_type", field = "jobType", name = "任务类型")
    @Column(name = "job_type")
    private Integer jobType;

     /** 源表名 */
    @LogField
    @ApiModelProperty(value = "源表名")
    @FieldRemark(column = "src_table_name", field = "srcTableName", name = "源表名")
    @Column(name = "src_table_name")
    private String srcTableName;

     /** 目标表名 */
    @LogField
    @ApiModelProperty(value = "目标表名")
    @FieldRemark(column = "dst_table_name", field = "dstTableName", name = "目标表名")
    @Column(name = "dst_table_name")
    private String dstTableName;

     /** 过滤条件 */
    @LogField
    @ApiModelProperty(value = "过滤条件")
    @FieldRemark(column = "filter_condition", field = "filterCondition", name = "过滤条件")
    @Column(name = "filter_condition")
    private String filterCondition;

    /**
     * 结构化和半结构化采集：待迁移或待同步列 [{"srcColumnName":"name","srcColumnType":"varchar(32)","dstColumnName":"test_name","dstColumnType":"varchar(32)","desensitizationRuleId":"","desensitizationPolicyId":"",
     * "modifyDstColumnName":"user_name_test"}]
     * 流式采集：[{"templateId":"100","tableName":"test","columnList":[{"srcColumnName":"name","srcColumnType":"varchar(32)","dstColumnName":"test_name","dstColumnType":"varchar(32)","desensitizationRuleId
     * ":"","desensitizationPolicyId":"","modifyDstColumnName":"user_name_test"}]}]
     */
    @ApiModelProperty(value = "待迁移或待同步列[{\"srcColumnName\":\"name\",\"srcColumnType\":\"varchar(32)\",\"dstColumnName\":\"test_name\",\"dstColumnType\":\"varchar(32)\",\"desensitizationRuleId\":\"\",\"desensitizationPolicyId\":\"\"}]")
    @FieldRemark(column = "mapping_column", field = "mappingColumn", name = "待迁移或待同步列")
    @Column(name = "mapping_column")
    private String mappingColumn;

     /** datax运行脚本 */
    @ApiModelProperty(value = "datax运行脚本")
    @FieldRemark(column = "datax_json", field = "dataxJson", name = "datax运行脚本")
    @Column(name = "datax_json")
    private String dataxJson;

     /** 同步方式:
      * 全量同步：1
      * 增量同步：0
      */
    @LogField
    @ApiModelProperty(value = "同步方式，全量同步：1，增量同步：0")
    @FieldRemark(column = "sync_mode", field = "syncMode", name = "同步方式")
    @Column(name = "sync_mode")
    private Integer syncMode;

     /** 是否修改列映射
      * 否：0
      * 是：1
      */
    @LogField
    @ApiModelProperty(value = "是否修改列映射，否：0，是：1")
    @FieldRemark(column = "modify_column", field = "modifyColumn", name = "是否修改列映射")
    @Column(name = "modify_column")
    private Integer modifyColumn;

     /** 选择的目标表 */
    @ApiModelProperty(value = "选择的目标表")
    @FieldRemark(column = "selected_target_table", field = "selectedTargetTable", name = "选择的目标表")
    @Column(name = "selected_target_table")
    private String selectedTargetTable;

     /** 历史数据是否存在更新的情况
      * 是：1，否：0
      */
    @LogField
    @ApiModelProperty(value = "历史数据是否存在更新的情况，是：1，否：0")
    @FieldRemark(column = "update_history_data", field = "updateHistoryData", name = "历史数据是否存在更新的情况")
    @Column(name = "update_history_data")
    private Integer updateHistoryData;

     /** 同步条件字段
      * 时间戳字段：1
      * 主键字段：2
      */
    @LogField
    @ApiModelProperty(value = "同步条件字段，时间戳字段：1，主键字段：2")
    @FieldRemark(column = "sync_condition_field", field = "syncConditionField", name = "同步条件字段")
    @Column(name = "sync_condition_field")
    private Integer syncConditionField;

     /** 同步条件字段名称 */
    @LogField
    @ApiModelProperty(value = "同步条件字段名称")
    @FieldRemark(column = "field_name", field = "fieldName", name = "同步条件字段名称")
    @Column(name = "field_name")
    private String fieldName;

     /** 时间戳字段-同步开始时间点 */
    @LogField
    @ApiModelProperty(value = "时间戳字段-同步开始时间点")
    @FieldRemark(column = "sync_time_point", field = "syncTimePoint", name = "时间戳字段-同步开始时间点")
    @Column(name = "sync_time_point")
    private Date syncTimePoint;

     /** 主键字段-同步的开始主键值 */
    @LogField
    @ApiModelProperty(value = "主键字段-同步的开始主键值")
    @FieldRemark(column = "sync_id_value", field = "syncIdValue", name = "主键字段-同步的开始主键值")
    @Column(name = "sync_id_value")
    private Long syncIdValue;

     /** hive配置json数据 */
    @ApiModelProperty(value = "hive配置json数据")
    @FieldRemark(column = "hive_json", field = "hiveJson", name = "hive配置json数据")
    @Column(name = "hive_json")
    private String hiveJson;

     /** iotdb配置json数据 */
    @ApiModelProperty(value = "iotdb配置json数据")
    @FieldRemark(column = "iotdb_json", field = "iotdbJson", name = "iotdb配置json数据")
    @Column(name = "iotdb_json")
    private String iotdbJson;

     /** 表是否被创建：
      * 未创建:0
      * 已创建:1
      */
    @ApiModelProperty(value = "表是否被创建：未创建:0，已创建:1")
    @FieldRemark(column = "is_created", field = "isCreated", name = "表是否被创建")
    @Column(name = "is_created")
    private Integer isCreated;

     /** 限速参数 */
    @LogField
    @ApiModelProperty(value = "限速参数")
    @FieldRemark(column = "speed_limit_param", field = "speedLimitParam", name = "限速参数")
    @Column(name = "speed_limit_param")
    private String speedLimitParam;

    /**
     * 是否删除，否：0，是：1
     */
    @LogField
    @ApiModelProperty(value = "是否删除，否：0，是：1")
    @FieldRemark(column = "flag", field = "flag", name = "是否删除")
    @Column(name = "flag")
    private Integer flag;

     /** 源表列字段 */
    @ApiModelProperty(value = "源表列字段")
    @Transient
    private List<ColumnInfo> srcColumnList;

     /** 源表列字段(适配流式) */
    @ApiModelProperty(value = "源表列字段")
    @Transient
    private Map<String, List<ColumnInfo>> srcColumnMap;

     /** 目标表列字段 */
    @ApiModelProperty(value = "目标表列字段")
    @Transient
    private List<ColumnInfo> dstColumnList;

     /** 目标表列字段(适配流式) */
    @ApiModelProperty(value = "目标表列字段")
    @Transient
    private Map<String, List<ColumnInfo>> dstColumnMap;

     /**  时间列字段 */
    @ApiModelProperty(value = "时间列字段")
    @Transient
    private List<ColumnInfo> timeColumnList;

     /** 主键列字段 */
    @ApiModelProperty(value = "主键列字段")
    @Transient
    private List<ColumnInfo> primaryKeyColumnList;

     /** iotdbJsonDto */
    @ApiModelProperty(value = "iotdbJsonDto")
    @Transient
    private IotdbJsonDto iotdbJsonDto;

     /** hiveJsonDto */
    @ApiModelProperty(value = "hiveJsonDto")
    @Transient
    private HiveJsonDto hiveJsonDto;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getJobId() {
        return jobId;
    }

    public void setJobId(String jobId) {
        this.jobId = jobId;
    }

    public Integer getJobType() {
        return jobType;
    }

    public void setJobType(Integer jobType) {
        this.jobType = jobType;
    }

    public String getSrcTableName() {
        return srcTableName;
    }

    public void setSrcTableName(String srcTableName) {
        this.srcTableName = srcTableName;
    }

    public String getDstTableName() {
        return dstTableName;
    }

    public void setDstTableName(String dstTableName) {
        this.dstTableName = dstTableName;
    }

    public String getFilterCondition() {
        return filterCondition;
    }

    public void setFilterCondition(String filterCondition) {
        this.filterCondition = filterCondition;
    }

    public String getMappingColumn() {
        return mappingColumn;
    }

    public void setMappingColumn(String mappingColumn) {
        this.mappingColumn = mappingColumn;
    }

    public String getDataxJson() {
        return dataxJson;
    }

    public void setDataxJson(String dataxJson) {
        this.dataxJson = dataxJson;
    }

    public Integer getSyncMode() {
        return syncMode;
    }

    public void setSyncMode(Integer syncMode) {
        this.syncMode = syncMode;
    }

    public Integer getModifyColumn() {
        return modifyColumn;
    }

    public void setModifyColumn(Integer modifyColumn) {
        this.modifyColumn = modifyColumn;
    }

    public String getSelectedTargetTable() {
        return selectedTargetTable;
    }

    public void setSelectedTargetTable(String selectedTargetTable) {
        this.selectedTargetTable = selectedTargetTable;
    }

    public Integer getUpdateHistoryData() {
        return updateHistoryData;
    }

    public void setUpdateHistoryData(Integer updateHistoryData) {
        this.updateHistoryData = updateHistoryData;
    }

    public Integer getSyncConditionField() {
        return syncConditionField;
    }

    public void setSyncConditionField(Integer syncConditionField) {
        this.syncConditionField = syncConditionField;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public Date getSyncTimePoint() {
        return syncTimePoint;
    }

    public void setSyncTimePoint(Date syncTimePoint) {
        this.syncTimePoint = syncTimePoint;
    }

    public Long getSyncIdValue() {
        return syncIdValue;
    }

    public void setSyncIdValue(Long syncIdValue) {
        this.syncIdValue = syncIdValue;
    }

    @Override
    public String getOrgIdentity() {
        return orgIdentity;
    }

    @Override
    public void setOrgIdentity(String orgIdentity) {
        this.orgIdentity = orgIdentity;
    }

    @Override
    public String getSecretLevel() {
        return secretLevel;
    }

    @Override
    public void setSecretLevel(String secretLevel) {
        this.secretLevel = secretLevel;
    }

    public List<ColumnInfo> getSrcColumnList() {
        return srcColumnList;
    }

    public void setSrcColumnList(List<ColumnInfo> srcColumnList) {
        this.srcColumnList = srcColumnList;
    }

    public List<ColumnInfo> getDstColumnList() {
        return dstColumnList;
    }

    public void setDstColumnList(List<ColumnInfo> dstColumnList) {
        this.dstColumnList = dstColumnList;
    }

    public List<ColumnInfo> getTimeColumnList() {
        return timeColumnList;
    }

    public void setTimeColumnList(List<ColumnInfo> timeColumnList) {
        this.timeColumnList = timeColumnList;
    }

    public List<ColumnInfo> getPrimaryKeyColumnList() {
        return primaryKeyColumnList;
    }

    public void setPrimaryKeyColumnList(List<ColumnInfo> primaryKeyColumnList) {
        this.primaryKeyColumnList = primaryKeyColumnList;
    }

    public Integer getIsCreated() {
        return isCreated;
    }

    public void setIsCreated(Integer isCreated) {
        this.isCreated = isCreated;
    }

    public String getHiveJson() {
        return hiveJson;
    }

    public void setHiveJson(String hiveJson) {
        this.hiveJson = hiveJson;
    }

    public String getIotdbJson() {
        return iotdbJson;
    }

    public void setIotdbJson(String iotdbJson) {
        this.iotdbJson = iotdbJson;
    }

    public IotdbJsonDto getIotdbJsonDto() {
        return iotdbJsonDto;
    }

    public void setIotdbJsonDto(IotdbJsonDto iotdbJsonDto) {
        this.iotdbJsonDto = iotdbJsonDto;
    }

    public HiveJsonDto getHiveJsonDto() {
        return hiveJsonDto;
    }

    public void setHiveJsonDto(HiveJsonDto hiveJsonDto) {
        this.hiveJsonDto = hiveJsonDto;
    }

    public Map<String, List<ColumnInfo>> getSrcColumnMap() {
        return srcColumnMap;
    }

    public void setSrcColumnMap(Map<String, List<ColumnInfo>> srcColumnMap) {
        this.srcColumnMap = srcColumnMap;
    }

    public Map<String, List<ColumnInfo>> getDstColumnMap() {
        return dstColumnMap;
    }

    public void setDstColumnMap(Map<String, List<ColumnInfo>> dstColumnMap) {
        this.dstColumnMap = dstColumnMap;
    }

    public String getSpeedLimitParam() {
        return speedLimitParam;
    }

    public void setSpeedLimitParam(String speedLimitParam) {
        this.speedLimitParam = speedLimitParam;
    }

    public Integer getFlag() {
        return flag;
    }

    public void setFlag(Integer flag) {
        this.flag = flag;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "任务管理";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "任务";
        } else {
            return super.logTitle;
        }
    }

}